/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.put.dcs_modeler.visualModelEditor.propertiesEditor.editors;



import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.logging.Logger;
import org.netbeans.api.java.project.JavaProjectConstants;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
import org.netbeans.spi.project.support.ProjectOperations;
import org.openide.filesystems.FileObject;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet;
import pl.put.dcs_modeler.visualModelEditor.propertiesEditor.propertyEditorsForClasses.ClassPathPropertyEditor;
import pl.put.model.computingObject.ComputingObject;
import pl.put.model.flowModel.flowComputingObjectElement.FlowComputingObjectElement;
/**
 *
 * @author LukaszR
 */
public class ComputingObjectPropertyEditor extends AbstractNode
{
    public static Logger log = Logger.getLogger( ComputingObjectPropertyEditor.class.getName() );
    private FlowComputingObjectElement flowCO;
    private Project project;

    public ComputingObjectPropertyEditor( FlowComputingObjectElement flowCO, Project project )
    {
        super( Children.LEAF );
        
        this.flowCO = flowCO;
        this.project = project;

    }
    
    

    @Override
    protected Sheet createSheet()
    {
        Sheet sheet = Sheet.createDefault();
        Sheet.Set set = Sheet.createPropertiesSet();
        //APIObject obj = getLookup().lookup( APIObject.class );

        try
        {

            ComputingObject co = flowCO.getComputingObject();
            /*
            Property id = new PropertySupport.Reflection( flowCO, int.class, "id" );
            id.setName( "Id" );
            set.put( id );
            */
            Property name = new PropertySupport.ReadOnly( "Name", String.class, "Name", "Flow object name" )
            {
                @Override
                public Object getValue() throws IllegalAccessException, InvocationTargetException
                {
                    return flowCO.getName();
                }
            };
            //name.setName( "Name" );
            set.put( name );

            Property coName = new PropertySupport.ReadOnly( "Computing object name", String.class, "Computing object name", "Computing object name" )
            {
                @Override
                public Object getValue() throws IllegalAccessException, InvocationTargetException
                {
                    return flowCO.getComputingObjectName();
                }
            };
            //coName.setName( "Computing object name" );
            set.put( coName );

            PropertySupport.Reflection agregatorPath = new PropertySupport.Reflection( flowCO, String.class, "dataDecompositorClassPath" );
            agregatorPath.setName( "Path to data decompositor class" );
            agregatorPath.setPropertyEditorClass( ClassPathPropertyEditor.class );
            agregatorPath.setValue( "project", project ); // dodanie parametru do wywolania 
            set.put( agregatorPath );

        }
        catch ( NoSuchMethodException ex )
        {
            log.warning( ex.getMessage() );
        }
        set.setDisplayName( "Flow computing object properties" );
        sheet.put( set );
        return sheet;


    }

}
